//等差数列划分
//测试链接：https://leetcode.cn/problems/arithmetic-slices/
public class NumberOfArithmeticSlices {
    public int numberOfArithmeticSlices(int[] nums)
    {
        int n = nums.length;
        int[] dp = new int[n];
        int sum = 0;
        for(int i = 2; i < n; i++)
        {
            dp[i] = nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2] ? dp[i
                    - 1] + 1 : 0;
            sum += dp[i];
        }
        return sum;
    }
}
